package com.vfa.data;

import java.util.ArrayList;

import com.vfa.file.FileInfo;
import com.vfa.vocaburay.R;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

public class EntryAdapter extends ArrayAdapter<Entry>{

	private Entry entry;
	ArrayList<Entry> entrys = new ArrayList<Entry>();
	private final LayoutInflater mInflater;
	private final int mLayoutRes;
	private Context context;
	private TextView tv_entryTitle, tv_entryDate;
	
	
	public EntryAdapter(Context context, int textViewResourceId , ArrayList<Entry> listEntry) {
		super(context, textViewResourceId, listEntry);
		
		this.context = context;
		entrys = listEntry;
		this.mLayoutRes = textViewResourceId;
		this.mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
	}
	
	@Override
	public int getCount() {
		return entrys.size();
	}

	@Override
	public Entry getItem(int position) {
		return entrys.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}
	
	@Override
	public View getView(final int position, View convertView, ViewGroup parent){
		View v;
		if(convertView == null){
			v=mInflater.inflate(mLayoutRes, parent, false);
		}
		else {
			v=convertView;
		}
		entry = entrys.get(position);
		final int listsize = entrys.size();
		if(entry !=null){
			tv_entryTitle = (TextView)v.findViewById(R.id.textView_EntryTitle);
			tv_entryDate = (TextView)v.findViewById(R.id.textView_EntryDate);
			
			if(tv_entryTitle !=null)
			{
				tv_entryTitle.setText(entry.getEntryTitle());
			}
			if(tv_entryDate !=null)
			{
				tv_entryDate.setText(entry.getEntryDate());
			}
		}
		return v;
	}

}
